home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / flilib.zip / FLISRC.ZIP / NORMPTR.ASM < prev    next >
Assembly Source File  |  1989-11-11  |  1KB  |  65 lines

  1.  
  2.     TITLE   normptr
  3.  
  4. _TEXT    SEGMENT  BYTE PUBLIC 'CODE'
  5. _TEXT    ENDS
  6. _DATA    SEGMENT  WORD PUBLIC 'DATA'
  7. _DATA    ENDS
  8. CONST    SEGMENT  WORD PUBLIC 'CONST'
  9. CONST    ENDS
  10. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  11. _BSS    ENDS
  12. DGROUP    GROUP    CONST,    _BSS,    _DATA
  13.     ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
  14. _TEXT      SEGMENT
  15.  
  16.     PUBLIC    _i86_norm_ptr
  17.     ;i86_norm_ptr(offset, seg)
  18.     ;Add as much as possible of the offset of a pointer to the segment
  19. _i86_norm_ptr    PROC far
  20.     push bp
  21.     mov bp,sp
  22.     push cx
  23.  
  24.     mov    ax,[bp+4+2]    ;offset
  25.     mov dx,[bp+6+2]   ;segment
  26.     mov cl,4
  27.     shr ax,cl
  28.     add dx,ax
  29.     mov    ax,[bp+4+2]    ;offset
  30.     and ax,15
  31.  
  32.     pop cx
  33.     pop    bp
  34.     ret    
  35. _i86_norm_ptr    ENDP
  36.  
  37.     PUBLIC    _i86_enorm_ptr
  38.     ;i86_norm_ptr(offset, seg)
  39.     ;Add as much as possible of the offset of a pointer to the segment
  40.     ;and make it evenly alligned...
  41. _i86_enorm_ptr    PROC far
  42.     push bp
  43.     mov bp,sp
  44.     push cx
  45.  
  46.     mov    ax,[bp+4+2]    ;offset
  47.     mov dx,[bp+6+2]   ;segment
  48.     inc ax
  49.     and ax,0FFFEh    ;force even allignment
  50.     mov [bp+4+2],ax ;and save...
  51.     mov cl,4
  52.     shr ax,cl
  53.     add dx,ax
  54.     mov    ax,[bp+4+2]    ;offset
  55.     and ax,15
  56.  
  57.     pop cx
  58.     pop    bp
  59.     ret    
  60. _i86_enorm_ptr    ENDP
  61.  
  62.  
  63. _TEXT    ENDS
  64. END
  65.